package com.waghost.bridalgown.controller;

import com.waghost.bridalgown.annotaion.Logging;
import com.waghost.bridalgown.entity.BridalGown;
import com.waghost.bridalgown.entity.Category;
import com.waghost.bridalgown.entity.Result;
import com.waghost.bridalgown.service.BridalGownService;
import com.waghost.bridalgown.service.CategoryService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
// 分类
@RestController
@CrossOrigin
@AllArgsConstructor
@RequestMapping("/cg")
public class CategoryController {

    private CategoryService categoryService;

    @GetMapping("/list")
    public Result list() {
        return categoryService.list();
    }

    @GetMapping("/get/{id}")
    public Result get(@PathVariable("id") Integer id) {
        return categoryService.getId(id);
    }

    @PostMapping("/add")
    @Logging(type = 1,uuid = 3)
    public Result addUser(@RequestBody Category category) {
        return categoryService.add(category);
    }

    @PostMapping("/edit")
    @Logging(type = 3,uuid = 3)
    public Result editUser(@RequestBody Category category) {
        return categoryService.update(category);
    }

    @PostMapping("/del/{id}")
    @Logging(type = 2,uuid = 3)
    public Result delUser(@PathVariable("id") Integer id) {
        return categoryService.delete(id);
    }


}
